<template>
  <div class="SearchAndList">
    <!-- 搜索栏结束 -->
    <div class="search" v-if="showSearch">
      <slot name="search"></slot>
    </div>
    <!-- 搜索栏结束 -->
    <!-- 显示栏开始 -->
    <div class="view">
      <!-- 默认开始 -->
      <slot></slot>
      <!-- 默认结束 -->
      <!-- 按钮开始 -->
      <div class="buttons" v-if="showButtons">
        <slot name="buttons"></slot>
      </div>
      <!-- 按钮结束 -->
      <!-- 列表开始 -->
      <div class="list" v-if="showList">
        <slot name="list"></slot>
      </div>
      <!-- 列表结束 -->
      <!-- 底部内容开始 -->
      <div class="bottom">
        <slot name="bottom"></slot>
      </div>
      <!-- 底部内容结束 -->
    </div>
    <!-- 显示栏结束 -->
  </div>
</template>

<script>
export default {
  data () {
    return {
      showSearch: false, // 搜索栏
      showButtons: false, // 按钮
      showList: false, // 列表
      showBottom: false // 底部
    }
  },
  created () {
    // 如果插入了就创建插槽的DIV
    if (this.$slots.search) this.showSearch = true // 搜索
    if (this.$slots.buttons) this.showButtons = true // 按钮
    if (this.$slots.list) this.showList = true // 列表
    if (this.$slots.bottom) this.showBottom = true // 底部
  }
}
</script>

<style lang="scss" scoped>
.SearchAndList {
  // 搜索框插入样式
  .search {
    height: 64px;
    margin-bottom: 20px;
    ::v-deep .el-form {
      display: flex;
      align-items: center;
      height: 100%;
      margin-left: 17px;
      .el-form-item {
        margin: 0;
        margin-right: .5em;
      }
    }
  }
  // 显示框样式
  .view {
    padding: 20px;
    // 按钮部分样式
    .buttons {
      display: flex;
      margin-bottom: 20px;
      ::v-deep .el-button {
        border: none;
        // 第一个按钮
        &:nth-child(1){
          width: 80px;
          color: #fff;
          background: linear-gradient(135deg,#ff9743,#ff5e20)!important;
          &:hover {
            background: linear-gradient(135deg,#ff7d43,#db3602)!important;
          }
        }
        // 第二个按钮
        &:nth-child(2){
          width: 80px;
          display: flex;
          align-items: center;
          justify-content: center;
          padding: 0;
          background-color: #fbf4f0!important;
          color: #655b56;
          &:hover {
            background-color: #f3e7e1!important;
          }
        }
      }
    }
    .list {
      ::v-deep .el-table {
        font-size: 13px;
        .el-table__header-wrapper {
          .cell {
            padding: 10px 0 10px 10px !important;
            font-weight: 400 !important;
            background: #f3f6fb;
            color: #666;
          }
        }
        .el-table__cell {
          padding: 0;
          border: none;
          .cell {
            padding: 5px 0 10px 10px;
          }
        }
      }
    }
    .bottom {
      margin: 32px 16px 12px 16px;
      ::v-deep .el-pagination{
        display: flex;
        .str {
          flex: 1;
          font-size: 16px;
          color: #dbdfe5;
          font-weight: 400;
        }
        .btn-prev, .btn-next {
          width: 70px;
          height: 32px;
          margin: 0 15px;
          background: #edf0f9;

        }
      }
    }
  }
  .search, .view {
    background: white;
  }
  ::v-deep .el-button--danger-text {
    color: #ff5a5a !important;
  }
}
</style>
